package com.moyq5.mvc.framework.dao;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.moyq5.mvc.framework.general.Page;
import com.moyq5.mvc.framework.general.Paging;
import com.moyq5.mvc.framework.general.Sort;
import com.moyq5.mvc.framework.general.Sorting;

/**
 * @author Moyq5
 * @date 2018年8月8日
 * @param <T>
 */
public abstract class BasicService<T, S extends T> implements Service<T, S> {
	
	protected static Logger log = LoggerFactory.getLogger(BasicService.class);
	
	protected abstract Dao<T, S> getDao();

	@Override
	public T one(Serializable id) {
		return getDao().one(id);
	}

	@Override
	public T one(S t4s) {
		return getDao().one(t4s);
	}

	@Override
	public T one(S t4s, String searchWord) {
		return getDao().one(t4s, searchWord);
	}

	@Override
	public T one(S t4s, List<Sort> sorts) {
		return getDao().one(t4s, sorts);
	}

	@Override
	public T one(S t4s, Sorting sort) {
		return getDao().one(t4s, sort);
	}

	@Override
	public T persist(T entity) {
		return getDao().persist(entity);
	}

	@Override
	public T merge(T entity) {
		return getDao().merge(entity);
	}
	
	@Override
	public void remove(Serializable id) {
		getDao().remove(getDao().one(id));
	}

	@Override
	public void remove(T entity) {
		getDao().remove(entity);
	}
	
	@Override
	public List<T> list(S t4s) {
		return getDao().list(t4s);
	}

	@Override
	public List<T> list(S t4s, String searchWord) {
		return getDao().list(t4s, searchWord);
	}

	@Override
	public List<T> list(S t4s, List<Sort> sorts) {
		return getDao().list(t4s, sorts);
	}

	@Override
	public List<T> list(S t4s, Sorting sort) {
		return getDao().list(t4s, sort);
	}

	@Override
	public Page<T> page(S t4s) {
		return getDao().page(t4s);
	}

	@Override
	public Page<T> page(S t4s, String searchWord) {
		return getDao().page(t4s, searchWord);
	}

	@Override
	public Page<T> page(S t4s, List<Sort> sorts) {
		return getDao().page(t4s, sorts);
	}

	@Override
	public Page<T> page(S t4s, Sorting si) {
		return getDao().page(t4s, si);
	}

	@Override
	public Page<T> page(S t4s, Paging pi) {
		return getDao().page(t4s, pi);
	}

	@Override
	public long count(S t4s) {
		return getDao().count(t4s);
	}

	@Override
	public long count(S t4s, String searchWord) {
		return getDao().count(t4s, searchWord);
	}

	@Override
	public void flush() {
		getDao().flush();
	}

}
